package gui;

import data.BankDatabase;
import data.User;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class AdmDelete extends JPanel{
	
	private JButton btn_Submit;
	private JLabel lbl_User;
	private JComboBox comboBox_Delete;
	private JButton btn_Back;
	private JLabel lbl_Header;
	
	private BankDatabase bdb;
	private Screen screen;
	
	public AdmDelete(BankDatabase bdb, Screen screen) {
		
		this.bdb = bdb;
		this.screen = screen; 
		
		setPreferredSize(new Dimension(550, 400));
		setLayout(null);
		
		btn_Submit = new JButton("Submit");
		btn_Submit.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Submit.setBounds(358, 300, 110, 40);
		add(btn_Submit);
		
		lbl_User = new JLabel("Which user do you want to delete?");
		lbl_User.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_User.setBounds(147, 125, 263, 21);
		add(lbl_User);

		comboBox_Delete = new JComboBox();
		comboBox_Delete.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox_Delete.setBounds(147, 170, 263, 30);
		add(comboBox_Delete);
		
		btn_Back = new JButton("Back");
		btn_Back.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Back.setBounds(52, 300, 102, 40);
		add(btn_Back);
		
		lbl_Header = new JLabel("Delete User");
		lbl_Header.setFont(new Font("SansSerif", Font.BOLD, 26));
		lbl_Header.setBounds(199, 59, 142, 34);
		add(lbl_Header);
	}
	
	public void addActionListener(ActionListener e){
		comboBox_Delete.addActionListener(e);
		btn_Back.addActionListener(e);
		btn_Submit.addActionListener(e);
	}
	
	public JButton getSubmit() {
		return btn_Submit;
	}
	
	public JButton getBack() {
		return btn_Back;
	}
	
	public JComboBox getComboBox() {
		return comboBox_Delete;
	}

	// adding all users to the combobox
	public void addAllUsers() {
		comboBox_Delete.removeAllItems();
		for (User usr : bdb.getUserList()) {
			   comboBox_Delete.addItem("CPR ID: " + usr.getCPR());
			}
		screen.pack();
	}
}
